package cn.groupmarket.domain.tag.service;

import cn.groupmarket.domain.tag.adapter.repository.ITagRepository;
import cn.groupmarket.domain.tag.model.entity.CrowdTagsJobEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class TagService implements ITagService{

    @Resource
    private ITagRepository tagRepository;

    @Override
    public void execTagBatchJob(String tagId, String batchId) {
        log.info("人群标签批次任务 tagId:{},batchId:{}", tagId, batchId);

        CrowdTagsJobEntity crowdTagsJobEntity = tagRepository.queryCrowdTagsJobEntity(tagId, batchId);

        List<String> userIdList = new ArrayList<String>(){{
            add("yg1");
            add("yg2");
            add("yg3");
        }};

        for (String userId : userIdList) {
            tagRepository.addCrowdTagsUserId(tagId, userId);
        }

        tagRepository.updateCrowdTagsStatisics(tagId,userIdList.size());
    }
}
